<template>
  <div class="adminMyFeedback">
    <div class="adminMsg">
      <h2>我的反馈</h2>
      <div class="title block">
        <span>反馈列表</span>
        <span>操作</span>
      </div>
      <div v-for="item in currentList" :key="item.id" >
        <div class="info block">
          <div class="msg">
            <h3>{{ item.title }}</h3>
            <p style="font-size: large;font-weight: 600;">反馈内容：{{ item.content }}</p>
            <p >反馈时间：{{ item.createTime }}</p>
            <p>回复人：{{ item.replyName }}</p>
            <p style="font-size: large;font-weight: 600">回复内容：{{item.replyContent}}</p>
            <p>
              回复状态：
              <el-tag v-if="item.status == 0" effect="dark" type="success">待回复</el-tag>
              <el-tag v-if="item.status == 1" effect="dark" type="danger">已回复</el-tag>
            </p>
            <p>回复时间：{{ item.replyTime }}</p>
          </div>
          <div >
            <el-button v-if="item.status==1" size="small" type="danger">删除</el-button>
            <p v-else>  </p>
          </div>
        </div>
      </div>
      <div class="Page">
        <el-pagination :current-page.sync="pageNum"
                       :page-size="pageSize"
                       :page-sizes="[3, 5, 7, 9, 20]"
                       :total="allList.length"
                       layout="total, sizes, prev, pager, next"
                       @current-change="handlePage"
                       @size-change="handleSizeChange"
        >
        </el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";

export default {
  name: "AdminMyFeedback",

  mounted() {
    this.getFeedback();
  },
  data() {
    return {
      currentList: [],
      list: [],
      allList: [],
      pageNum: 1,
      pageSize: 3,
    }
  },
  methods: {

    getFeedback() {
      axios({
        url: "/feedback/myFeedback",
        method: 'get',
      }).then(res => {
        if(res.code === '200'){
          this.allList = res.data;
          this.handlePage(1)
        }else
          this.$message.warning(res.msg)
      })
    },

    handleSizeChange(size) {
      this.pageSize = size;
      this.pageNum = 1;
      this.handlePage(1,size)

    },

    handlePage(page) {
      this.pageNum = page;
      const start = (page - 1) * this.pageSize;
      const end = page * this.pageSize;
      this.currentList = this.allList.slice(start, end);
    },
  },
}
</script>

<style scoped>
.adminMyFeedback{
  width: 1110px;
  min-height: 750px;
  background-color: white;
  padding: 20px 50px;
}

.adminMsg{
  width: 1155px;
  min-height: 850px;
  background-color: white;
  border-radius: 15px;
  padding: 20px 90px 10px 20px;
  box-shadow: 0 0px 14px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04)
}

.adminMsg h2 {
  font-size: 20px;
  font-weight: 600;
  margin-buttom: 15px;
  margin-left: 0px;
}
.Page {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

.block {
  display: block;
  display: flex;
  align-items: center;
  width: 1195px;
}
.block> :first-child{
  flex: 4;
}

.block> :nth-child(n+2){
  flex: 1;
  text-align: center;
}

.title {
  height: 50px;
  background-color: #4b5fff;
  color: white;
  padding-left: 20px;
  margin-top: 20px;
}

.info {
  height: 230px;
  padding: 30px 20px 30px 0;
  border-bottom: 1px solid #eee;
}

.info .msg {
  color: #777;
  line-height: 20px;
  margin-left: 18px;
}

.msg h3 {
  font-size: 18px;
  color: black;
  font-weight: 600;
  margin-bottom: 5px;
}
</style>